package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ComputesTheScalarProductOfTwoArray {
	public static void main(String[] argv) {
		double[] w0 = new double[]{34.45, 35.45, 36.67, 37.78, 37.0000,
				37.1234, 67.2344, 68.34534, 69.87700};
		double[] w1 = new double[]{34.45, 35.45, 36.67, 37.78, 37.0000,
				37.1234, 67.2344, 68.34534, 69.87700};
		System.out.println("两个数组的标量积:" + scalarProduct(w0, w1));
	}

	public static double scalarProduct(double[] w0, double[] w1) {
		double sortie = 0.0;
		for (int k = 0; k < w0.length; k++) {
			sortie += w0[k] * w1[k];
		}
		return (sortie);
	}


	public static int scalarProduct(int[] w0, int[] w1) {
		int sortie = 0;
		for (int k = 0; k < w0.length; k++) {
			sortie = sortie + w0[k] * w1[k];
		}
		return (sortie);
	}
}
